import React, {Component} from 'react'
import {Link} from 'react-router'
import '../sass/GoodsItem'

export default class GoodsItem extends Component {
  constructor() {
    super()

    this.state = {
      ifSpecification: false,
		haveSpecification: true
    }
  }

  _showSpecification = param => {
  	this.setState({ifSpecification: param})
  }

  render() {
    const {data, from} = this.props

    return (
    	<div className="goods-item-wrapper">
			<div className={from === 'category' ? 'goods-item-category' : 'goods-item'}>
				<Link><img src={require('../images/goods_default.png')}/></Link>
				<div className="info">
					<p className="name">进口蓝莓超甜进口蓝莓超甜进口蓝莓超甜进口蓝莓超甜进口蓝莓超甜</p>
					<p className="price">￥999起</p>
					{
						!this.state.haveSpecification ?
						<div className="addCart"><i className="iconfont s2b-jia"/></div> :
						!this.state.ifSpecification ?
						<div className="specification" onClick={this._showSpecification.bind(this, true)}>选规格<i className="iconfont s2b-jiantou"/></div> :
						<div className="specification" onClick={this._showSpecification.bind(this, false)}>收起<i className="iconfont s2b-jiantou-shang"/></div>
					}
				</div>
			</div>
			{
				this.state.ifSpecification &&
				<div className="specification-item-wrapper">
					<div className="specification-item">
						<p className="price">￥999/袋(3斤)</p>
						<div className="addCart"><i className="iconfont s2b-jia"/></div>
					</div>
				</div>
			}
		</div>
    )
  }
}
